
package authentication;

import com.sun.org.apache.xml.internal.security.utils.Base64;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Encrypter {
    MessageDigest md5;
    public Encrypter(){
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException ex) {
        	System.out.println("The system doesn't suport MD5");
        }
    }

    public String encrypt(String str){
        byte[] digest = null;
        try {
            digest = md5.digest(str.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException ex) {
        }
        return Base64.encode(digest);
    }
}
